﻿using Services;
using UnityEngine;

namespace Gobang
{
    public abstract class ChessPlayer : MonoBehaviour
    {
        public int targetChess;    //1表示执黑子，2表示执白子
        protected ChessboardMono chessboard;
        protected GameManager gameManager;

        protected virtual void Awake()
        {
            chessboard = ChessboardMono.FindInstance();
            gameManager = ServiceLocator.Get<GameManager>();
        }

        protected virtual bool CanPlay()
        {
            return gameManager.isPlaying
                && chessboard.nextChess == targetChess;
        }

        protected virtual void Update() { }
    }
}